package com.itlin.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itlin.bean.SetmealDish;
import com.itlin.dao.SetmealDishDao;
import com.itlin.service.SetmealDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 所谓伊人
 * @date 2022/3/26 - 21:27
 */
@Transactional
@Service
public class SetmealDishServiceImpl implements SetmealDishService {

    @Autowired
    private SetmealDishDao dao;

    @Override
    public int add(SetmealDish setmealDish) {
        return dao.insert(setmealDish);
    }

    @Override
    public int delete(List<Long> ids) {
        LambdaQueryWrapper<SetmealDish> qw = new LambdaQueryWrapper<>();
        qw.in(SetmealDish::getSetmealId , ids);
        return dao.delete(qw);
    }

    @Override
    public int deleteByDishId(List<Long> ids){
        LambdaQueryWrapper<SetmealDish> qw = new LambdaQueryWrapper<>();
        qw.in(SetmealDish::getDishId , ids);
        return dao.delete(qw);
    };
}
